#include <math.h>
#include <stdio.h>

#include <algorithm>

using namespace std;

typedef long long ll;

ll N;

// 这个基于基本不等式的解法是错误的，正解：
// https://blog.csdn.net/xiaoquantouer/article/details/70142739

const int MOD = 5218;

double product_upper(double x, int n) { return pow(x / n, n); }

double maximum(double x) { return pow(2, log2(x) - 1); }

void FindMaxIndex(ll& mval_flr, ll& mval_ceil) {
  double mval = maximum(N);
  mval_flr = floor(mval);
  mval_ceil = ceil(mval);
  if (fabs(mval_flr - mval_ceil) < 1e-5) {
    mval_flr -= 1;
  }
}

ll ModPow(ll x, ll n) {
  // 带模快速幂。
  x %= MOD;
  if (n == 1) {
    return x;
  }
  if (n == 0) {
    return 1;
  }
  ll temp = ModPow(x, n / 2);
  temp = (temp * temp) % MOD;
  if (n % 2 == 0) {
    return temp;
  }
  temp = (temp * x) % MOD;
  return temp;
}

ll FindMax(ll n) {
  // 分的越平均，就越接近最大值。
  ll D = N / n;
  ll M = N % n;
  ll ans;

  if (M == 0) {
    ans = ModPow(D, n);
  } else {
    ans = ModPow(D, n - M) * ModPow(D + 1, M);
  }
  return ans % MOD;
}

void Solve() {
  if (N == 2) {
    puts("2");  // 2 = 2
    return;
  }
  if (N == 1) {
    puts("1");  // 1 = 1
    return;
  }

  ll mval_flr, mval_ceil;
  FindMaxIndex(mval_flr, mval_ceil);
  ll max_flr = FindMax(mval_flr);
  ll max_ceil = FindMax(mval_ceil);
  ll ans = max(max_flr, max_ceil);
  printf("%lld %lld\n", mval_flr, mval_ceil);
  printf("%lld\n", ans);
}

int main() {
  //   scanf("%lld", &N);
  N = 20;
  Solve();
  return 0;
}